package com.java2007.zhangyu.restaurant.entity;

/**
 * 返回结果实体
 * @author zy
 * @version
 * @date 2021/01/29
 */
public class Result {
    /**
     * 成功：true
     * 失败：false
     */
    private boolean success;
    /**
     * 返回的信息
     */
    private String message;
    /**
     * 附加数据
     *     若增加失败，data就可以写失败的原因
     *     若增加成功，就可以是查询列表的数据
     */
    private Object data;

    public Result() {}

    public Result(boolean success, String message, Object data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Result ok(String message){
        return new Result(true, message, null);
    }

    public static Result ok(String message, Object data){
        return new Result(true, message, data);
    }

    public static Result fail(String message){
        return new Result(false, message, null);
    }

    public static Result fail(String message, Object data){
        return new Result(false, message, data);
    }

}
